<?php

namespace App\Transformers\Web;

use App\Models\Category;
use League\Fractal\TransformerAbstract;

class RankTransformer extends TransformerAbstract
{
    public function transform($studentResult)
    {

        return [
            'user_id' => $studentResult->user_id,
            'fraction' => $studentResult->fraction,
            'username' => $studentResult->username,
            'subject' => Category::query()->where('id', $studentResult->subject_id)->pluck('name'),
            'timer' => $studentResult->timer,
        ];
    }
}

